package com.example.upload.config;

import cn.dev33.satoken.stp.StpUtil;
import com.example.upload.exception.BusinessRuntimeException;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author lsx
 * @description: TODO
 * @date 2024年06月07日 17:00
 * @Version: 1.0
 */
@Aspect
@Component
public class LoginStatusHandle {

    @Pointcut("@annotation(com.example.upload.annotation.LoginStatus)")
    public void loginStatusPointCut(){}


    @Before("loginStatusPointCut()")
    public void loginStatus() {
        if (!StpUtil.isLogin()){
            throw new BusinessRuntimeException("请先登录后再进行操作！");
        }
    }
}
